Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d3-collection

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-collection

Handy data structures for elements keyed by string.

  • 1.0.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
increased by0.71%
Maintainers
1
Weekly downloads
 
Created

What is d3-collection?

The d3-collection npm package is part of the D3.js library and provides utilities for manipulating associative arrays, also known as maps or dictionaries, and sets. It is useful for organizing and managing data collections in JavaScript.

What are d3-collection's main functionalities?

Map

The Map feature allows you to create and manipulate key-value pairs. You can set, get, and remove entries in the map.

const d3 = require('d3-collection');
const map = d3.map();
map.set('key1', 'value1');
map.set('key2', 'value2');
console.log(map.get('key1')); // Output: 'value1'

Nest

The Nest feature allows you to group array elements into a nested structure based on a specified key. This is useful for organizing hierarchical data.

const d3 = require('d3-collection');
const data = [
  {category: 'A', value: 1},
  {category: 'B', value: 2},
  {category: 'A', value: 3}
];
const nestedData = d3.nest()
  .key(d => d.category)
  .entries(data);
console.log(nestedData);

Set

The Set feature allows you to create a collection of unique values. You can add, remove, and check for the existence of values in the set.

const d3 = require('d3-collection');
const set = d3.set();
set.add('value1');
set.add('value2');
console.log(set.has('value1')); // Output: true

Keys

The Keys feature allows you to extract the keys from an object as an array. This is useful for iterating over the properties of an object.

const d3 = require('d3-collection');
const obj = {a: 1, b: 2, c: 3};
const keys = d3.keys(obj);
console.log(keys); // Output: ['a', 'b', 'c']

Values

The Values feature allows you to extract the values from an object as an array. This is useful for iterating over the values of an object.

const d3 = require('d3-collection');
const obj = {a: 1, b: 2, c: 3};
const values = d3.values(obj);
console.log(values); // Output: [1, 2, 3]

Entries

The Entries feature allows you to extract the key-value pairs from an object as an array of objects with 'key' and 'value' properties. This is useful for iterating over the entries of an object.

const d3 = require('d3-collection');
const obj = {a: 1, b: 2, c: 3};
const entries = d3.entries(obj);
console.log(entries); // Output: [{key: 'a', value: 1}, {key: 'b', value: 2}, {key: 'c', value: 3}]

Other packages similar to d3-collection

Keywords

FAQs

Package last updated on 24 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc